﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Text;


public partial class ybqy_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection sqlcon = new SqlConnection();
        sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
        sqlcon.Open();

        SqlCommand sqlcmd = new SqlCommand("select * from a01101 where  qiyeid=" + Session["qiyeid"], sqlcon);
        SqlDataReader reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);
        string str = "";


        if (!IsPostBack)
        {
            if (reader.Read())
            {            //先判断是否有今年的
                reader.Close();
                sqlcon.Open();
                str = "select * from a01101 where ShenBaoNianDu='" + Session["ShenBaoNianDu"] + "' and qiyeid=" + Session["qiyeid"];
                sqlcmd.CommandText = str;
                reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);
                if (reader.Read())
                {

                    FACT_ADDRESS.Text = reader["FACT_ADDRESS"].ToString();
                    MASTER_DEP.Text = reader["MASTER_DEP"].ToString();
                    WORK_NUMBER.Text = reader["WORK_NUMBER"].ToString();
                    ENV_PEOPLE.Text = reader["ENV_PEOPLE"].ToString();
                    FACT_TEL.Text = reader["FACT_TEL"].ToString();
                    FAX.Text = reader["FAX"].ToString();
                    E_MAIL.Text = reader["E_MAIL"].ToString();
                    POST_ADDRESS.Text = reader["POST_ADDRESS"].ToString();
                    water_facility_type.Text = reader["water_facility_type"].ToString();
                    STARTWORK_TIME.Text = reader["STARTWORK_TIME"].ToString();
                    WORKINGDAYOFYEAR.Text = reader["WORKINGDAYOFYEAR"].ToString();
                    EMPLOYEEOFYEAR.Text = reader["EMPLOYEEOFYEAR"].ToString();
                    BANK_NAME.Text = reader["BANK_NAME"].ToString();
                    BANK_NUM.Text = reader["BANK_NUM"].ToString();
                    PRODUCTIONOFYEAR.Text = reader["PRODUCTIONOFYEAR"].ToString();
                    TAXOFYEAR.Text = reader["TAXOFYEAR"].ToString();
                    PRODUCTION_VALUE.Text = reader["PRODUCTION_VALUE"].ToString();
                    MERITOFYEAR.Text = reader["MERITOFYEAR"].ToString();
                    EQUIPVALUEOFYEAR.Text = reader["EQUIPVALUEOFYEAR"].ToString();
                    FACILITY_NUM.Text = reader["FACILITY_NUM"].ToString();
                    DISPOSE_ABILITY.Text = reader["DISPOSE_ABILITY"].ToString();
                    RUN_MONEY.Text = reader["RUN_MONEY"].ToString();
                    BOILER_NUM.Text = reader["BOILER_NUM"].ToString();
                    BIOLER_CNT.Text = reader["BIOLER_CNT"].ToString();
                    GAS_SUITNUM.Text = reader["GAS_SUITNUM"].ToString();
                    SUFLUR_SUITNUM.Text = reader["SUFLUR_SUITNUM"].ToString();
                    yc_BIOLER_CNT.Text = reader["yc_BIOLER_CNT"].ToString();
                    so2_BIOLER_CNT.Text = reader["so2_BIOLER_CNT"].ToString();
                    INDUSTRY_NUM.Text = reader["INDUSTRY_NUM"].ToString();
                    INDUGAS_SUITNUM.Text = reader["INDUGAS_SUITNUM"].ToString();
                    INDSUFLUR_SUITNUM.Text = reader["INDSUFLUR_SUITNUM"].ToString();
                    GASFACILITY_NUM.Text = reader["GASFACILITY_NUM"].ToString();
                    GASFACILITY_ABILITY.Text = reader["GASFACILITY_ABILITY"].ToString();
                    GASFACILITY_MONEY.Text = reader["GASFACILITY_MONEY"].ToString();
                    SUFLURFACILITY_NUM.Text = reader["SUFLURFACILITY_NUM"].ToString();
                    SUFLURFACILITY_ABILITY.Text = reader["SUFLURFACILITY_ABILITY"].ToString();
                    PERMIT_CODE1.Text = reader["PERMIT_CODE1"].ToString();
                    PERMIT_DATE1.Text = reader["PERMIT_DATE1"].ToString();
                    PERMIT_CODE2.Text = reader["PERMIT_CODE2"].ToString();
                    PERMIT_DATE2.Text = reader["PERMIT_DATE2"].ToString();
                    PERMIT_CODE3.Text = reader["PERMIT_CODE3"].ToString();
                    PERMIT_DATE3.Text = reader["PERMIT_DATE3"].ToString();
                    CHARGEOFYEAR.Text = reader["CHARGEOFYEAR"].ToString();
                    AMERCEOFYEAR.Text = reader["AMERCEOFYEAR"].ToString();

                    if (reader["FACT_SCALE"].ToString() != "")
                    {
                        DropDownList1.SelectedValue = reader["FACT_SCALE"].ToString();

                    }
                    if (reader["FACT_TYPE"].ToString() != "")
                    {
                        DropDownList2.SelectedValue = reader["FACT_TYPE"].ToString();

                    }
                    if (reader["FACT_HAVINGTYPE"].ToString() != "")
                    {
                        DropDownList3.SelectedValue = reader["FACT_HAVINGTYPE"].ToString();

                    }
                    if (reader["FACT_KIND"].ToString() != "")
                    {
                        DropDownList4.SelectedValue = reader["FACT_KIND"].ToString();

                    }
                    if (reader["FOCUS_TYPE"].ToString() != "")
                    {
                        DropDownList5.SelectedValue = reader["FOCUS_TYPE"].ToString();

                    }
                    if (reader["PROJECT_NAME"].ToString() != "")
                    {
                        DropDownList6.SelectedValue = reader["PROJECT_NAME"].ToString();

                    }
                    if (reader["TRADE_CODE"].ToString() != "")
                    {
                        DropDownList7.SelectedValue = reader["TRADE_CODE"].ToString();
                    }
                    if (reader["XAIS"].ToString() != "")
                    {
                        Label3.Text = reader["XAIS"].ToString().Substring(0, 3) + "度" + reader["XAIS"].ToString().Substring(3, 2) + "分" + reader["XAIS"].ToString().Substring(5, 2) + "秒";
                    }
                    else
                    {
                        Label3.Text = "";
                    }
                    if (reader["YAIS"].ToString() != "")
                    {
                        Label4.Text = reader["YAIS"].ToString().Substring(0, 2) + "度" + reader["YAIS"].ToString().Substring(2, 2) + "分" + reader["YAIS"].ToString().Substring(4, 2) + "秒";
                    }
                    else
                    {
                        Label4.Text = "";
                    }
                }
                else
                {
                    reader.Close();
                    sqlcon.Open();
                    str = "select max(id) as id from a01101 where  qiyeid=" + Session["qiyeid"];
                    sqlcmd.CommandText = str;
                    reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);
                    if (reader.Read())
                    {
                        str = "select * from a01101 where id=" + reader["id"].ToString() + " and qiyeid=" + Session["qiyeid"];
                        reader.Close();
                        sqlcon.Open();
                        sqlcmd.CommandText = str;
                        reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);

                        if (reader.Read())
                        {
                            FACT_ADDRESS.Text = reader["FACT_ADDRESS"].ToString();
                            MASTER_DEP.Text = reader["MASTER_DEP"].ToString();
                            WORK_NUMBER.Text = reader["WORK_NUMBER"].ToString();
                            ENV_PEOPLE.Text = reader["ENV_PEOPLE"].ToString();
                            FACT_TEL.Text = reader["FACT_TEL"].ToString();
                            FAX.Text = reader["FAX"].ToString();
                            E_MAIL.Text = reader["E_MAIL"].ToString();
                            POST_ADDRESS.Text = reader["POST_ADDRESS"].ToString();
                            water_facility_type.Text = reader["water_facility_type"].ToString();
                            STARTWORK_TIME.Text = reader["STARTWORK_TIME"].ToString();
                            WORKINGDAYOFYEAR.Text = reader["WORKINGDAYOFYEAR"].ToString();
                            EMPLOYEEOFYEAR.Text = reader["EMPLOYEEOFYEAR"].ToString();
                            BANK_NAME.Text = reader["BANK_NAME"].ToString();
                            BANK_NUM.Text = reader["BANK_NUM"].ToString();
                        }
                    }
                }
            }
        }
        reader.Close();

        SqlCommand sqlcmd1 = new SqlCommand("select youzhengbianma from system_status", sqlcon);
        sqlcon.Open();
        TextBox8.Text = sqlcmd1.ExecuteScalar().ToString();

        reader.Close();
        sqlcon.Close();

    }
    public string DisplayStr()
    {
        YingYongHanShu yyhs = new YingYongHanShu();

        return yyhs.DisplayStr2("101101");
    }

    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

    }
    protected void TextBox18_TextChanged(object sender, EventArgs e)
    {

    }

    public void xiedaoshujuku()
    {
        SqlConnection sqlcon = new SqlConnection();
        sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
        sqlcon.Open();

        SqlCommand sqlcmd = new SqlCommand("select * from  a01101 where ShenBaoNianDu='" + Session["ShenBaoNianDu"] + "' and qiyeid=" + Session["qiyeid"], sqlcon);

        SqlDataReader reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);
        //Response.Write(TextBox3.Text);

        if (reader.Read())
        {
            string FACT_FOCUSvalues = DropDownList5.SelectedValue;
            if (FACT_FOCUSvalues == "4")
            {
                FACT_FOCUSvalues = "0";

            }
            else
            {
                FACT_FOCUSvalues = "1";
            }

            string d1, d2, d3, d4;
            d1 = STARTWORK_TIME.Text.Trim();
            if (STARTWORK_TIME.Text.Trim() == "1900-1-1 0:00:00") { d1 = ""; }

            d2 = PERMIT_DATE1.Text.Trim();
            if (PERMIT_DATE1.Text.Trim() == "1900-1-1 0:00:00") { d2 = ""; }

            d3 = PERMIT_DATE2.Text.Trim();
            if (PERMIT_DATE2.Text.Trim() == "1900-1-1 0:00:00") { d3 = ""; }

            d4 = PERMIT_DATE3.Text.Trim();
            if (PERMIT_DATE3.Text.Trim() == "1900-1-1 0:00:00") { d4 = ""; }




            string sqlstr = @"update a01101 set 
            FACT_ADDRESS='" + FACT_ADDRESS.Text.Trim() + "',"
+ "MASTER_DEP='" + MASTER_DEP.Text.Trim() + "',"
+ "WORK_NUMBER='" + WORK_NUMBER.Text.Trim() + "',"
+ "ENV_PEOPLE='" + ENV_PEOPLE.Text.Trim() + "',"
+ "FACT_TEL='" + FACT_TEL.Text.Trim() + "',"
+ "FAX='" + FAX.Text.Trim() + "',"
+ "E_MAIL='" + E_MAIL.Text.Trim() + "',"
+ "POST_ADDRESS='" + POST_ADDRESS.Text.Trim() + "',"
+ "POST_CODE='" + TextBox8.Text.Trim() + "',"
+ "water_facility_type='" + water_facility_type.Text.Trim() + "',";
            if (STARTWORK_TIME.Text.Trim() != "")
            {
                sqlstr = sqlstr + "STARTWORK_TIME='" + STARTWORK_TIME.Text.Trim() + "',";
            }
            sqlstr = sqlstr + "WORKINGDAYOFYEAR='" + WORKINGDAYOFYEAR.Text.Trim() + "',"
            + "EMPLOYEEOFYEAR='" + EMPLOYEEOFYEAR.Text.Trim() + "',"
            + "FACT_SCALE='" + DropDownList1.SelectedValue + "',"
            + "FACT_TYPE='" + DropDownList2.SelectedValue + "',"
            + "FACT_HAVINGTYPE='" + DropDownList3.SelectedValue + "',"
            + "FACT_KIND='" + DropDownList4.SelectedValue + "',"
            + "TRADE_CODE='" + DropDownList7.SelectedValue + "',"
            + "BANK_NAME='" + BANK_NAME.Text.Trim() + "',"
            + "BANK_NUM='" + BANK_NUM.Text.Trim() + "',"
            + "PRODUCTIONOFYEAR='" + PRODUCTIONOFYEAR.Text.Trim() + "',"
            + "TAXOFYEAR='" + TAXOFYEAR.Text.Trim() + "',"
            + "PRODUCTION_VALUE='" + PRODUCTION_VALUE.Text.Trim() + "',"
            + "MERITOFYEAR='" + MERITOFYEAR.Text.Trim() + "',"
            + "EQUIPVALUEOFYEAR='" + EQUIPVALUEOFYEAR.Text.Trim() + "',"
            + "FACILITY_NUM='" + FACILITY_NUM.Text.Trim() + "',"
            + "DISPOSE_ABILITY='" + DISPOSE_ABILITY.Text.Trim() + "',"
            + "RUN_MONEY='" + RUN_MONEY.Text.Trim() + "',"
            + "BOILER_NUM='" + BOILER_NUM.Text.Trim() + "',"
            + "BIOLER_CNT='" + BIOLER_CNT.Text.Trim() + "',"
            + "GAS_SUITNUM='" + GAS_SUITNUM.Text.Trim() + "',"
            + "SUFLUR_SUITNUM='" + SUFLUR_SUITNUM.Text.Trim() + "',"
            + "yc_BIOLER_CNT='" + yc_BIOLER_CNT.Text.Trim() + "',"
            + "so2_BIOLER_CNT='" + so2_BIOLER_CNT.Text.Trim() + "',"
            + "INDUSTRY_NUM='" + INDUSTRY_NUM.Text.Trim() + "',"
            + "INDUGAS_SUITNUM='" + INDUGAS_SUITNUM.Text.Trim() + "',"
            + "INDSUFLUR_SUITNUM='" + INDSUFLUR_SUITNUM.Text.Trim() + "',"
            + "GASFACILITY_NUM='" + GASFACILITY_NUM.Text.Trim() + "',"
            + "GASFACILITY_ABILITY='" + GASFACILITY_ABILITY.Text.Trim() + "',"
            + "GASFACILITY_MONEY='" + GASFACILITY_MONEY.Text.Trim() + "',"
            + "SUFLURFACILITY_NUM='" + SUFLURFACILITY_NUM.Text.Trim() + "',"
            + "SUFLURFACILITY_ABILITY='" + SUFLURFACILITY_ABILITY.Text.Trim() + "',"
            + "PERMIT_CODE1='" + PERMIT_CODE1.Text.Trim() + "',";
            if (PERMIT_DATE1.Text.Trim() != "")
            {
                sqlstr = sqlstr + "PERMIT_DATE1='" + PERMIT_DATE1.Text.Trim() + "',";
            }
            sqlstr = sqlstr + "PERMIT_CODE2='" + PERMIT_CODE2.Text.Trim() + "',";
            if (PERMIT_DATE2.Text.Trim() != "")
            {
                sqlstr = sqlstr + "PERMIT_DATE2='" + PERMIT_DATE2.Text.Trim() + "',";
            }
            sqlstr = sqlstr + "PERMIT_CODE3='" + PERMIT_CODE3.Text.Trim() + "',";
            if (PERMIT_DATE3.Text.Trim() != "")
            {
                sqlstr = sqlstr + "PERMIT_DATE3='" + PERMIT_DATE3.Text.Trim() + "',";
            }
            sqlstr = sqlstr + "PROJECT_NAME='" + DropDownList6.SelectedValue + "',"
            + "FACT_FOCUS='" + FACT_FOCUSvalues + "',"
            + "FOCUS_TYPE='" + DropDownList5.SelectedValue + "',"
            + "CHARGEOFYEAR='" + CHARGEOFYEAR.Text.Trim() + "',"
            + "AMERCEOFYEAR='" + AMERCEOFYEAR.Text.Trim() + "',"
            + "jy='weijiaoyan'" + " where ShenBaoNianDu='" + Session["ShenBaoNianDu"] + "' and qiyeid=" + Session["qiyeid"];

            reader.Close();
            sqlcon.Open();
            SqlCommand sqlcmd1 = new SqlCommand(sqlstr, sqlcon);

            sqlcmd1.ExecuteNonQuery();

        }
        else
        {
            string sqlstr = @"insert into  a01101 ([qiyeid],[ShenBaoNianDu] ) values (" + Session["qiyeid"] + ",'" + Session["ShenBaoNianDu"] + "')";

            //Response.Write(sqlstr);

            reader.Close();
            sqlcon.Open();
            SqlCommand sqlcmd1 = new SqlCommand(sqlstr, sqlcon);

            sqlcmd1.ExecuteNonQuery();

            string FACT_FOCUSvalues = DropDownList5.SelectedValue;
            if (FACT_FOCUSvalues == "4")//当控制等级为4时，FACT_FOCUSvalues=0
            {
                FACT_FOCUSvalues = "0";

            }
            else
            {
                FACT_FOCUSvalues = "1";
            }
            string d1, d2, d3, d4;
            d1 = STARTWORK_TIME.Text.Trim();
            if (STARTWORK_TIME.Text.Trim() == "1900-1-1 0:00:00") { d1 = ""; }

            d2 = PERMIT_DATE1.Text.Trim();
            if (PERMIT_DATE1.Text.Trim() == "1900-1-1 0:00:00") { d2 = ""; }

            d3 = PERMIT_DATE2.Text.Trim();
            if (PERMIT_DATE2.Text.Trim() == "1900-1-1 0:00:00") { d3 = ""; }

            d4 = PERMIT_DATE3.Text.Trim();
            if (PERMIT_DATE3.Text.Trim() == "1900-1-1 0:00:00") { d4 = ""; }




            sqlstr = @"update a01101 set 
            FACT_ADDRESS='" + FACT_ADDRESS.Text.Trim() + "',"
+ "MASTER_DEP='" + MASTER_DEP.Text.Trim() + "',"
+ "WORK_NUMBER='" + WORK_NUMBER.Text.Trim() + "',"
+ "ENV_PEOPLE='" + ENV_PEOPLE.Text.Trim() + "',"
+ "FACT_TEL='" + FACT_TEL.Text.Trim() + "',"
+ "FAX='" + FAX.Text.Trim() + "',"
+ "E_MAIL='" + E_MAIL.Text.Trim() + "',"
+ "POST_ADDRESS='" + POST_ADDRESS.Text.Trim() + "',"
+ "POST_CODE='" + TextBox8.Text.Trim() + "',"
+ "water_facility_type='" + water_facility_type.Text.Trim() + "',";
            if (STARTWORK_TIME.Text.Trim() != "")
            {
                sqlstr = sqlstr + "STARTWORK_TIME='" + STARTWORK_TIME.Text.Trim() + "',";
            }
            sqlstr = sqlstr + "WORKINGDAYOFYEAR='" + WORKINGDAYOFYEAR.Text.Trim() + "',"
            + "EMPLOYEEOFYEAR='" + EMPLOYEEOFYEAR.Text.Trim() + "',"
            + "FACT_SCALE='" + DropDownList1.SelectedValue + "',"
            + "FACT_TYPE='" + DropDownList2.SelectedValue + "',"
            + "FACT_HAVINGTYPE='" + DropDownList3.SelectedValue + "',"
            + "FACT_KIND='" + DropDownList4.SelectedValue + "',"
            + "TRADE_CODE='" + DropDownList7.SelectedValue + "',"
            + "BANK_NAME='" + BANK_NAME.Text.Trim() + "',"
            + "BANK_NUM='" + BANK_NUM.Text.Trim() + "',"
            + "PRODUCTIONOFYEAR='" + PRODUCTIONOFYEAR.Text.Trim() + "',"
            + "TAXOFYEAR='" + TAXOFYEAR.Text.Trim() + "',"
            + "PRODUCTION_VALUE='" + PRODUCTION_VALUE.Text.Trim() + "',"
            + "MERITOFYEAR='" + MERITOFYEAR.Text.Trim() + "',"
            + "EQUIPVALUEOFYEAR='" + EQUIPVALUEOFYEAR.Text.Trim() + "',"
            + "FACILITY_NUM='" + FACILITY_NUM.Text.Trim() + "',"
            + "DISPOSE_ABILITY='" + DISPOSE_ABILITY.Text.Trim() + "',"
            + "RUN_MONEY='" + RUN_MONEY.Text.Trim() + "',"
            + "BOILER_NUM='" + BOILER_NUM.Text.Trim() + "',"
            + "BIOLER_CNT='" + BIOLER_CNT.Text.Trim() + "',"
            + "GAS_SUITNUM='" + GAS_SUITNUM.Text.Trim() + "',"
            + "SUFLUR_SUITNUM='" + SUFLUR_SUITNUM.Text.Trim() + "',"
            + "yc_BIOLER_CNT='" + yc_BIOLER_CNT.Text.Trim() + "',"
            + "so2_BIOLER_CNT='" + so2_BIOLER_CNT.Text.Trim() + "',"
            + "INDUSTRY_NUM='" + INDUSTRY_NUM.Text.Trim() + "',"
            + "INDUGAS_SUITNUM='" + INDUGAS_SUITNUM.Text.Trim() + "',"
            + "INDSUFLUR_SUITNUM='" + INDSUFLUR_SUITNUM.Text.Trim() + "',"
            + "GASFACILITY_NUM='" + GASFACILITY_NUM.Text.Trim() + "',"
            + "GASFACILITY_ABILITY='" + GASFACILITY_ABILITY.Text.Trim() + "',"
            + "GASFACILITY_MONEY='" + GASFACILITY_MONEY.Text.Trim() + "',"
            + "SUFLURFACILITY_NUM='" + SUFLURFACILITY_NUM.Text.Trim() + "',"
            + "SUFLURFACILITY_ABILITY='" + SUFLURFACILITY_ABILITY.Text.Trim() + "',"
            + "PERMIT_CODE1='" + PERMIT_CODE1.Text.Trim() + "',";
            if (PERMIT_DATE1.Text.Trim() != "")
            {
                sqlstr = sqlstr + "PERMIT_DATE1='" + PERMIT_DATE1.Text.Trim() + "',";
            }
            sqlstr = sqlstr + "PERMIT_CODE2='" + PERMIT_CODE2.Text.Trim() + "',";
            if (PERMIT_DATE2.Text.Trim() != "")
            {
                sqlstr = sqlstr + "PERMIT_DATE2='" + PERMIT_DATE2.Text.Trim() + "',";
            }
            sqlstr = sqlstr + "PERMIT_CODE3='" + PERMIT_CODE3.Text.Trim() + "',";
            if (PERMIT_DATE3.Text.Trim() != "")
            {
                sqlstr = sqlstr + "PERMIT_DATE3='" + PERMIT_DATE3.Text.Trim() + "',";
            }
            sqlstr = sqlstr + "PROJECT_NAME='" + DropDownList6.SelectedValue + "',"
            + "FACT_FOCUS='" + FACT_FOCUSvalues + "',"
            + "FOCUS_TYPE='" + DropDownList5.SelectedValue + "',"
            + "CHARGEOFYEAR='" + CHARGEOFYEAR.Text.Trim() + "',"
            + "AMERCEOFYEAR='" + AMERCEOFYEAR.Text.Trim() + "',"
            + "jy='weijiaoyan'" + "  where ShenBaoNianDu='" + Session["ShenBaoNianDu"] + "' and qiyeid=" + Session["qiyeid"];

            reader.Close();
            sqlcon.Close();
            sqlcon.Open();
            SqlCommand sqlcmd2 = new SqlCommand(sqlstr, sqlcon);

            sqlcmd2.ExecuteNonQuery();

        }

        reader.Close();
        sqlcon.Close();


    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        Label5.Text = "更新中...";
        TextBox52.Text = "";
        xiedaoshujuku();

        string jy = "";
        int yzcw = 0;

        if (FACT_ADDRESS.Text == "")
        {
            FACT_ADDRESS.BackColor = System.Drawing.Color.Red;
            jy = "单位地址不能为空。\n";
            yzcw = 1;
        }

        if (FACT_ADDRESS.Text.IndexOf("路") > 0 || FACT_ADDRESS.Text.IndexOf("村") > 0 || FACT_ADDRESS.Text.IndexOf("街") > 0 || FACT_ADDRESS.Text.IndexOf("巷") > 0)
        {

        }
        else
        {
            FACT_ADDRESS.BackColor = System.Drawing.Color.Red;
            jy = "单位地址必须包含“路”、“村”、“街”、“巷”等字中的一个。\n";
            yzcw = 1;

        }

        if (ENV_PEOPLE.Text == "")
        {
            ENV_PEOPLE.BackColor = System.Drawing.Color.Red;
            jy = jy + "联系人不能为空。\n";
            yzcw = 1;
        }
        if (FACT_TEL.Text == "")
        {
            FACT_TEL.BackColor = System.Drawing.Color.Red;
            jy = jy + "联系电话不能为空。\n";
            yzcw = 1;
        }
        else
        {
            if (FACT_TEL.Text.Substring(0, 1) != "1")
            {
                if (FACT_TEL.Text.Substring(0, 1) != "0")
                {
                    FACT_TEL.BackColor = System.Drawing.Color.Red;
                    jy = jy + "联系电话需加区号。\n";
                    yzcw = 1;
                }
            }
            else
            {
                if (FACT_TEL.Text.Length != 11)
                {
                    FACT_TEL.BackColor = System.Drawing.Color.Red;
                    jy = jy + "联系电话位数错。\n";
                    yzcw = 1;
                }
            }
        }
        int a = 0;
        if (E_MAIL.Text != "")
        {
            a = E_MAIL.Text.IndexOf("@");
            if (a < 2)
            {
                E_MAIL.BackColor = System.Drawing.Color.Yellow;
                jy = jy + "电子邮件格式错。\n";

            }
            a = E_MAIL.Text.IndexOf(".");
            if (a < 4)
            {
                E_MAIL.BackColor = System.Drawing.Color.Yellow;
                jy = jy + "电子邮件格式错。\n";

            }
        }
        if (WORKINGDAYOFYEAR.Text == "")
        {
            WORKINGDAYOFYEAR.BackColor = System.Drawing.Color.Red;
            jy = jy + "上年生产(经营)天数不能为空。\n";
            yzcw = 1;
        }
        else
        {
            if (float.Parse(WORKINGDAYOFYEAR.Text) >= 366)
            {
                WORKINGDAYOFYEAR.BackColor = System.Drawing.Color.Red;
                jy = jy + "上年生产(经营)天数不能大于366天。\n";
                yzcw = 1;
            }
            if (float.Parse(WORKINGDAYOFYEAR.Text) <= 0)
            {
                WORKINGDAYOFYEAR.BackColor = System.Drawing.Color.Red;
                jy = jy + "上年生产(经营)天数错。\n";
                yzcw = 1;
            }

            if (IsDate(STARTWORK_TIME.Text))
            {
                if (DateTime.Parse(DateTime.Now.Year.ToString() + "-1-1") <= DateTime.Parse(STARTWORK_TIME.Text))
                {
                    WORKINGDAYOFYEAR.BackColor = System.Drawing.Color.Red;
                    jy = jy + "上年生产(经营)天数错,上年未投产，应为空。\n";
                    yzcw = 1;

                }
                //上年投产
                if (DateTime.Parse((float.Parse(DateTime.Now.Year.ToString()) - 1).ToString() + "-1-1") <= DateTime.Parse(STARTWORK_TIME.Text))
                {
                    int b = 0;
                    string dqrq = DateTime.Now.Year.ToString() + "-1-1 0:00:00";
                    TimeSpan d3 = DateTime.Parse(dqrq).Subtract(DateTime.Parse(STARTWORK_TIME.Text));
                    a = d3.Days - 1;
                    b = int.Parse(WORKINGDAYOFYEAR.Text);

                    if (a > b)
                    {
                        WORKINGDAYOFYEAR.BackColor = System.Drawing.Color.Red;
                        jy = jy + "上年生产(经营)天数错,上年投产当天不应算入。 \n";
                        yzcw = 1;
                    }
                    if (a < b)
                    {
                        WORKINGDAYOFYEAR.BackColor = System.Drawing.Color.Red;
                        jy = jy + "上年生产(经营)天数错。   \n";
                        yzcw = 1;
                    }
                }
            }
            else
            {
                STARTWORK_TIME.BackColor = System.Drawing.Color.Red;
                jy = jy + "投产（开业）日期错。\n";
                yzcw = 1;

            }
        }

        if (PRODUCTIONOFYEAR.Text == "")
        {
            PRODUCTIONOFYEAR.BackColor = System.Drawing.Color.Red;
            jy = jy + "上年总产值不能为空。\n";
            yzcw = 1;
        }
        else
        {
            if (float.Parse(PRODUCTIONOFYEAR.Text) < float.Parse(TAXOFYEAR.Text))
            {
                PRODUCTIONOFYEAR.BackColor = System.Drawing.Color.Red;
                jy = jy + "上年总产值(万元)应大于等于上年年利税金额(万元)。\n";
                yzcw = 1;
            }
            if (PRODUCTION_VALUE.Text != "")
            {
                if (float.Parse(PRODUCTIONOFYEAR.Text) < float.Parse(PRODUCTION_VALUE.Text))
                {
                    PRODUCTIONOFYEAR.BackColor = System.Drawing.Color.Red;
                    jy = jy + "上年总产值(万元)应大于等于上年“三废”综合利用产品产值(万元)。\n";
                    yzcw = 1;
                }
            }
            if (CHARGEOFYEAR.Text != "")
            {
                if (float.Parse(PRODUCTIONOFYEAR.Text) < float.Parse(CHARGEOFYEAR.Text))
                {
                    PRODUCTIONOFYEAR.BackColor = System.Drawing.Color.Red;
                    jy = jy + "上年总产值(万元)应大于等于上年缴纳排污费总额(万元)。\n";
                    yzcw = 1;
                }
            }
            if (AMERCEOFYEAR.Text != "")
            {
                if (float.Parse(PRODUCTIONOFYEAR.Text) < float.Parse(AMERCEOFYEAR.Text))
                {
                    PRODUCTIONOFYEAR.BackColor = System.Drawing.Color.Red;
                    jy = jy + "上年总产值(万元)应大于等于上年环境违法罚款(万元 ) 。\n";
                    yzcw = 1;
                }
            }
        }

        if (float.Parse(DropDownList1.SelectedValue) < 6)
        {
            if (TAXOFYEAR.Text == "")
            {
                TAXOFYEAR.BackColor = System.Drawing.Color.Red;
                jy = jy + "贵企业属于中大型企业，请填写上年利税金额。\n";
                yzcw = 1;
            }
        }
        if (MERITOFYEAR.Text == "")
        {
            MERITOFYEAR.BackColor = System.Drawing.Color.Red;
            jy = jy + "上年末固定资产原值不能为空。\n";
            yzcw = 1;
        }
        if (EQUIPVALUEOFYEAR.Text == "")
        {
            EQUIPVALUEOFYEAR.BackColor = System.Drawing.Color.Red;
            jy = jy + "环保设施原值不能为空。\n";
            yzcw = 1;
        }
        else
        {
            if (float.Parse(MERITOFYEAR.Text) < float.Parse(EQUIPVALUEOFYEAR.Text))
            {
                EQUIPVALUEOFYEAR.BackColor = System.Drawing.Color.Red;
                jy = jy + "上年年末固定资产原值(万元)应大于等于环保设施原值(万元)。\n";
                yzcw = 1;
            }
        }
        if (FACILITY_NUM.Text != "")
        {
            if (DISPOSE_ABILITY.Text == "")
            {
                DISPOSE_ABILITY.BackColor = System.Drawing.Color.Red;
                jy = jy + "污水治理设施数不为空，污水治理设施处理能力不能为空。\n";
                yzcw = 1;
            }
            if (RUN_MONEY.Text == "")
            {
                RUN_MONEY.BackColor = System.Drawing.Color.Red;
                jy = jy + "污水治理设施数不为空，污水治理设施处理能力不能为空。\n";
                yzcw = 1;
            }
        }
        if (BOILER_NUM.Text != "")
        {
            if (float.Parse(DISPOSE_ABILITY.Text) < float.Parse(GAS_SUITNUM.Text))
            {
                GAS_SUITNUM.BackColor = System.Drawing.Color.Red;
                jy = jy + "锅炉数(台)应大于等于其中烟尘排放达标数。\n";
                yzcw = 1;
            }
            if (float.Parse(DISPOSE_ABILITY.Text) < float.Parse(SUFLUR_SUITNUM.Text))
            {
                SUFLUR_SUITNUM.BackColor = System.Drawing.Color.Red;
                jy = jy + "锅炉数(台)应大于等于33.其中二氧化硫排放达标数。\n";
                yzcw = 1;
            }
            if (BIOLER_CNT.Text == "")
            {
                BIOLER_CNT.BackColor = System.Drawing.Color.Red;
                jy = jy + "30.锅炉数数不为空，31.锅炉总蒸吨数不能为空。\n";
                yzcw = 1;
            }
        }

        if (yzcw == 0)//BIOLER_CNT
        {
            SqlConnection sqlcon = new SqlConnection();
            sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
            sqlcon.Open();

            SqlCommand sqlcmd = new SqlCommand("update  a01101 set jy='ruanjian' where ShenBaoNianDu='" + Session["ShenBaoNianDu"] + "' and qiyeid=" + Session["qiyeid"], sqlcon);
            sqlcmd.ExecuteNonQuery();
            sqlcon.Close();
            Label5.Text = "更新完成";
        }
        else
        {
            Label5.Text = "更新有错误";
            TextBox52.Text = jy;
        }

    }
    protected void FACILITY_NUM_TextChanged(object sender, EventArgs e)
    {

    }
    public bool IsDate(string str)
    {
        try
        {
            DateTime.Parse(str);
            return true;
        }
        catch
        {
            return false;
        }
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        xiedaoshujuku();

        SqlConnection sqlcon = new SqlConnection();
        sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
        sqlcon.Open();

        SqlCommand sqlcmd = new SqlCommand("update  a01101 set XAIS='',YAIS='' where ShenBaoNianDu='" + Session["ShenBaoNianDu"] + "' and qiyeid=" + Session["qiyeid"], sqlcon);
        sqlcmd.ExecuteNonQuery();
        sqlcon.Close();

        Response.Redirect("zzb.aspx");
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        xiedaoshujuku();

        Response.Redirect("hylx.aspx");

    }
}